home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / audio.h < prev    next >
C/C++ Source or Header  |  1995-10-23  |  12KB  |  440 lines

  1. /* Header File for Actua Soccer Audio */
  2.  
  3. #if     !defined(__AUDIO_H)
  4. #define __AUDIO_H
  5.  
  6. //************************************************************************************************
  7. // General
  8. //************************************************************************************************
  9.  
  10. extern short int CrowdVolume;
  11. extern short int PitchVolume;
  12. extern short int CommentaryVolume;
  13. extern short int MusicVolume;
  14. extern short int MasterVolume;
  15.  
  16. typedef struct tagmadfile
  17.     {
  18.     char name[16];
  19.     unsigned long int offset;
  20.     unsigned long int length;
  21.     }madfile;
  22.  
  23. enum                            // Team names
  24.     {
  25.     HOME_TEAM,
  26.     AWAY_TEAM
  27.     };
  28.  
  29. struct memstatus
  30.     {
  31.     unsigned long int ext;                // Running total for Extended memory allocations
  32.     unsigned long int base;                // Running total for Base memory allocations
  33.     unsigned long int fail;                // Running total for Failed memory allocations
  34.     };
  35.  
  36. // Structure for storing a sample in memory
  37.  
  38. typedef struct tagmemsam
  39.     {
  40.     char *name;                                // Name of the samples disk file
  41.     unsigned char *mem;                    // Pointer to the sample when in memory
  42.     long int size;                            // Length of the sample when in memory
  43.     unsigned short int flags;
  44.     }memsam;
  45.  
  46. // Memory Sample Flags
  47.  
  48. #define MSF_LOADING    0x01                // Sample is currently loading (ie dont play)
  49. #define MSF_DONTKEEP    0x02                // Sample should not be kept in memory after use (ie free it)
  50. #define MSF_PLAYED    0x04                // Sample has already been played.
  51.  
  52. //************************************************************************************************
  53. // Front End
  54. //************************************************************************************************
  55.  
  56. #define MAX_FRONTEND_SAMPLES 4
  57.  
  58. enum
  59.     {
  60.     FS_CROWD,                // Crowd sample
  61.     FS_PITCH,                // Pitch Sample
  62.     FS_COMMENT,                // Commetary
  63.     FS_CHEAT                    // Cheat Sample
  64.     };
  65.  
  66. //************************************************************************************************
  67. // Pitch
  68. //************************************************************************************************
  69.  
  70. #define MAX_PITCH_SAMPLES 20
  71.  
  72. enum
  73.     {
  74.     MS_AMBI2,                // Low Crowd Ambience
  75.     MS_AMBI4,                // Low Crowd Ambience (Alternative)
  76.     MS_AMBI6,                // Low Crowd Ambience (Alternative)
  77.     MS_AMBI8,                // Low Crowd Ambience (Alternative)
  78.     MS_GOAL,                    // Crowd Cheers for a goal
  79.     MS_MISS,                    // Crowd Just Missed (Ooooh)
  80.     MS_SAVE,                    // Great Save (Claps)
  81.     MS_LAUGH,                // Fluff (Laughs)
  82.     MS_FOWL,
  83.     MS_RESTLESS,            // Crowd Cheers for a goal
  84.     MS_LNGREF,                // Long referee whistle
  85.     MS_SHRTREF,                // Short referee whistle
  86.     MS_HRDKICK,                // Hard Kick
  87.     MS_KICK1,                // Kick
  88.     MS_PASS1,                // Kick
  89.     MS_BOOT,                    // Kick
  90.     MS_BOUNCE,                // Bounce
  91.     MS_FALL,                    // Sliding Tackle
  92.     MS_FULL,                    // Full time whistle
  93.     MS_HALF                    // Half time whistle
  94. //    MS_C_FOWL,
  95. //    MS_C_MISS,
  96. //    MS_CHANT0,                // Random Chant for Variety
  97. //    MS_CHANT1,                // Random Chant for Variety
  98. //    MS_CHANT2,                // Random Chant for Variety
  99. //    MS_CHANT3,                // Random Chant for Variety
  100. //    MS_CHANT4,                // Random Chant for Variety
  101. //    MS_CHANT5                // Random Chant for Variety
  102.     };
  103.  
  104. // Sound effects for on the pitch, The frequency will be altered slightly for variety
  105.  
  106. enum
  107. {
  108.     PS_NULL,                        // Diddly Squat
  109.  
  110.     PS_LONGWHISTLE,            // Various Whistles
  111.     PS_SHORTWHISTLE,
  112.     PS_HALFTIMEWHISTLE,
  113.     PS_FULLTIMEWHISTLE,
  114.  
  115.     PS_SOFTKICK,                // Various Ball Kicks
  116.     PS_MEDKICK,
  117.     PS_HARDKICK,
  118.  
  119.     PS_SOFTHEAD,                // Various Headers
  120.     PS_HARDHEAD,
  121.  
  122.     PS_SOFTCATCH,                // Various Handling of the Ball
  123.     PS_HARDCATCH,
  124.     PS_PUNCH,
  125.  
  126.     PS_SOFTBOUNCE,                // Various Ball Bounces
  127.     PS_HARDBOUNCE,
  128.  
  129.     PS_SOFTWOOD,                // Various Ball Rebounds off the Woodwork
  130.     PS_HARDWOOD,
  131.  
  132. //    PS_SOFTFOUL,                // Various Fouls
  133. //    PS_MEDFOUL,
  134. //    PS_HARDFOUL,
  135.  
  136.     PS_SLIDING,                    // Sliding Tackle
  137.  
  138.     PS_SOFTGOAL,                // Various Balls Hitting the back of the net
  139.     PS_HARDGOAL
  140. };
  141.  
  142. typedef struct tagpitchsam
  143.     {
  144.     memsam *info;
  145.     short int amp;                            // Amplitude of Sample (volume 0x0 - 0x7fff)
  146.     long int freq;                            // Frequency Divider (typically 0x8000 - half)
  147.     unsigned short int flags;
  148.     }pitchsam;
  149.  
  150. #define PSF_THREED    0x01                // Use Pan and Volume from the call (3D Sound)
  151. #define PSF_APPROX    0x02                // Play the sample at approximately the correct freqeuncy for Variety
  152.  
  153. //************************************************************************************************
  154. // Crowd
  155. //************************************************************************************************
  156.  
  157. enum
  158. {
  159.     CS_NULL,                        // Diddly Squat
  160.  
  161.     CS_AMBIENCE1,                // Various Ambience levels
  162.     CS_AMBIENCE2,
  163.     CS_AMBIENCE3,
  164.     CS_AMBIENCE4,
  165.     CS_GOAL,                        // Triggerd cheers
  166.     CS_RESTLESS,
  167.     CS_MISS,
  168.     CS_SAVE,
  169.     CS_LAUGH,
  170.     CS_FOWL
  171. //    CS_CHANT0,                    // Crowd Chants
  172. //    CS_CHANT1,                    // Crowd Chants
  173. //    CS_CHANT2,                    // Crowd Chants
  174. //    CS_CHANT3,                    // Crowd Chants
  175. //    CS_CHANT4,                    // Crowd Chants
  176. //    CS_CHANT5                    // Crowd Chants
  177. };
  178.  
  179. // Crowd noise definitions... (mood)
  180.  
  181. enum
  182. {
  183.     CN_OFF,
  184.  
  185.     CN_NORMAL,
  186.     CN_PENSIVE,
  187.     CN_ENCOURAGING,
  188.     CN_EXCITED,
  189.     CN_CELEBRATE,
  190.     CN_BOO,
  191.     CN_SAVE,
  192.     CN_MISS,
  193.     CN_LAUGH,
  194.     CN_FOWL
  195. };
  196.  
  197. struct crowdsam
  198. {
  199.     long int mood;                    // Current mood of Crowd
  200.     long int tranmood;            // Mood in for transition to
  201.     long int mainhandle;            // Main sample handle of crowd sample
  202.     long int mainvol;                // Volume of main crowd sample
  203.     long int maindelta;            // Volume difference of main crowd sample
  204.     long int mergehandle;        // Sample handle of Merging Crowd Sample
  205.     long int mergevol;            // Volume of Merging Crowd Sample
  206.     long int mergedelta;            // Volume Difference of Merging Sample
  207.     long int volmax;                // Maximum volume crowd can reach
  208.     long int pan;                    // Pan Position of Crowd Sample
  209.     long int pandelta;            // Pan Difference of Crowd Sample
  210.     long int ticks;                // Number of Ticks since last random event
  211.     long int nextevent;            // Number of Ticks to next event
  212.     short int flags;                // Flags to control the above
  213. };
  214.  
  215. // Events currently happening in the Crowd Update
  216.  
  217. #define CF_PAN     0x01
  218. #define CF_TRAN    0x02
  219.  
  220. //************************************************************************************************
  221. // Commentary
  222. //************************************************************************************************
  223.  
  224. #define MAX_REPEAT_BUFFER 64        // Amount of samples that must be played before a repeat
  225. #define MAX_REPEAT_ATTEMPTS 4        // Amount of attempts to find a sample that does not repeat
  226.  
  227. #define MAX_LINKS 4                    // Maximum amount of samples that can be load into link buffer
  228.  
  229. #define MAX_COMMENTARY_CATEGORIES 35
  230.  
  231. // Maximum Samples for each commentary category
  232.  
  233. enum                            // Team Intonation
  234.     {
  235.     TI_WELCOME,
  236.     TI_AND_NAME,
  237.     TI_NAME
  238.     };
  239.  
  240. enum                            // Player Intonation
  241.     {
  242.     PI_OWN_HALF,
  243.     PI_OPPONENTS_HALF,
  244.     PI_SHOOTING
  245.     };
  246.  
  247. enum
  248.     {
  249.     CM_NULL,
  250.  
  251.     SP_CORNER,                // Set piece
  252.     SP_GOALKICK,
  253.     SP_THROWIN,
  254.     SP_LONGTHROWIN,
  255.     SP_PENALTY,
  256.  
  257.     FU_FREEKICK,            // Foul
  258.     FU_WALL,
  259.     FU_BADFOUL,
  260.     FU_YELLOWCARD,
  261.     FU_REDCARD,
  262.     FU_INJURY,
  263.     FU_DIVE,
  264.  
  265.     CP_LONG,                    // Completed pass
  266.     CP_SHORT,
  267.     CP_TARGET,
  268.     CP_HEAD,
  269.     CP_NICEMOVE,
  270.     CP_SETPIECE,
  271.  
  272.     FP_LONG,                    // Failed Pass
  273.     FP_SHORT,
  274.     FP_LOOSE,
  275.  
  276.     GL_GENERIC,                // Goal
  277.     GL_DEFLECT,
  278.     GL_HARDKICK,
  279.     GL_HEADER,
  280.     GL_KEEPER,
  281.     GL_POST,
  282.     GL_CURVE,
  283.     GL_CURVEWALL,
  284.  
  285.     PM_CATCH,                // Player missed goal attempt
  286.     PM_BLOCK,
  287.     PM_WIDE,
  288.     PM_CLOSE,
  289.     PM_POST,
  290.     PM_CROSSBAR,
  291.  
  292.     MC_PREMATCH,
  293.     OT_GOODPLAY,
  294.     OT_POORPLAY,
  295.  
  296.     SU_ONFOR,
  297.     SU_TEAM,
  298.     SU_INJURED,
  299.  
  300.     TI_HALFTIME,
  301.     TI_FULLTIME,
  302.  
  303.     CM_LINKBANK
  304.     };
  305.  
  306. #define MAX_SP_CORNER         12
  307. #define MAX_SP_GOALKICK        8
  308. #define MAX_SP_THROWIN         5
  309. #define MAX_SP_LONGTHROWIN 6
  310. #define MAX_SP_PENALTY        24
  311.  
  312. #define MAX_FU_FREEKICK        9
  313. #define MAX_FU_WALL            9
  314. #define MAX_FU_BADFOUL        15
  315. #define MAX_FU_YELLOWCARD    8
  316. #define MAX_FU_REDCARD        9
  317. #define MAX_FU_INJURY        8
  318. #define MAX_FU_DIVE            8
  319.  
  320. #define MAX_CP_LONG            6
  321. #define MAX_CP_SHORT            4
  322. #define MAX_CP_TARGET        20
  323. #define MAX_CP_HEAD            2
  324. #define MAX_CP_NICEMOVE        7
  325. #define MAX_CP_SETPIECE        13
  326.  
  327. #define MAX_FP_LONG            3
  328. #define MAX_FP_SHORT            2
  329. #define MAX_FP_LOOSE            8
  330.  
  331. #define MAX_GL_GENERIC        36
  332. #define MAX_GL_DEFLECT        8
  333. #define MAX_GL_HARDKICK        8
  334. #define MAX_GL_HEADER        15
  335. #define MAX_GL_KEEPER        9
  336. #define MAX_GL_POST            8
  337. #define MAX_GL_CURVE            7
  338. #define MAX_GL_CURVEWALL    4
  339.  
  340. #define MAX_PM_CATCH            21
  341. #define MAX_PM_BLOCK            14
  342. #define MAX_PM_WIDE            21
  343. #define MAX_PM_CLOSE            16
  344. #define MAX_PM_POST            8
  345. #define MAX_PM_CROSSBAR        11
  346.  
  347. #define MAX_MC_PREMATCH        19
  348. #define MAX_OT_GOODPLAY        26
  349. #define MAX_OT_POORPLAY        13
  350.  
  351. #define MAX_SU_ONFOR            4
  352. #define MAX_SU_TEAM            5
  353. #define MAX_SU_INJURED        4
  354.  
  355. struct commcat
  356.     {
  357.     char name[4];
  358.     short int count;
  359.     };
  360.  
  361. typedef struct tagintonsam
  362.     {
  363.     memsam x;        // x,y,z are types of Intonation
  364.     memsam y;
  365.     memsam z;
  366.     }intonsam;
  367.  
  368. typedef struct tagteamsam
  369.     {
  370.     int team;                // Number of team in game data
  371.     intonsam country;
  372.     intonsam manager;
  373.     intonsam players[11];
  374.     }teamsam;
  375.  
  376. //************************************************************************************************
  377. // External Functions
  378. //************************************************************************************************
  379.  
  380. extern unsigned long int InitMatchAudio(unsigned long int seed);
  381. extern void UpdateVolumeLevels(void);
  382.  
  383. extern long int StartMusic(char *name,int volume);
  384. extern void StopMusic(void);
  385. extern long int UpdateMusic(void);
  386. extern int CheckMusic(void);
  387.  
  388. extern unsigned long int LoadPitchSamples(void);
  389. extern void FreePitchSamples(void);
  390. extern long int PlayPitchSample(int sam,short int amp,short int pan);
  391.  
  392. extern void StartCrowd(int team);
  393. extern void StopAudio(void);
  394. extern long int PlayCrowdSample(int sam);
  395. extern void UpdateCrowd(int mood,int team);
  396.  
  397. extern unsigned long int LoadTeamSamples(int team_num,int team);
  398. extern void FreeTeamSamples(int team);
  399.  
  400. extern unsigned long int LoadFrontEndSamples(void);
  401. extern void FreeFrontEndSamples(void);
  402.  
  403. extern unsigned long int LoadCommentarySamples(void);
  404. extern void FreeCommentarySamples(void);
  405. extern void UpdateCommentary(void);
  406. extern void PauseCommentary(void);
  407. extern void ResumeCommentary(void);
  408.  
  409. extern long int PlayTeamSample(int player,int intonation);
  410. extern void PlayWelcomeMessage(void);
  411. extern void PlaySubstitutionMessage(int team,int player_off,int player_on,int injured);
  412. extern void PlayScoreSample(int home,int away);
  413. extern void PlayCommentaryMessage(int type);
  414. extern void PlayPossessionSample(int team);
  415. extern long int PlayFrontEndSample(int sam,int amp);
  416.  
  417. //************************************************************************************************
  418. // Internal Functions
  419. //************************************************************************************************
  420.  
  421. void FreeLinkBank(void);
  422. short int CheckCommentary(void);
  423.  
  424. void CreateMusicFileName(char *name,char *dest);
  425. void CreateScoreFileName(char *home,char *away,char *mad,char *dest);
  426. void CreatePitchFileName(char *name,char *mad,char *dest);
  427. void CreatePlayerFileName(char *country,char *number,char *intonation,char *mad,char *dest);
  428. void CreateCommentaryFileName(char *category,char *number,char *mad,char *dest);
  429. void CreateFrontEndFileName(char *category,char *name,char *mad,char *dest);
  430.  
  431. int LoadSample(char *mad,char *name,memsam *bank,struct memstatus *MemStatus);
  432. void FreeSample(memsam *bank);
  433. void LoadCommentarySample(char *category,int samples,memsam *bank);
  434. int MADFindFile(FILE *fp,char *name);
  435. int CheckRepeatBuffer(char *category,int num);
  436. void ShowMemoryUsage(memstatus MemStatus,char *title);
  437. void LogText(char *format,...);
  438.  
  439. #endif  /* __AUDIO_H */
  440.